

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SiteManager;
using System.Data.SqlClient;
public partial class Featureddoc : System.Web.UI.UserControl
{
    Manager mgr = new Manager(true, "ConnectionString");
    public string dr_id = "0";
    public string featured_doc = "";
    public string top_rated_doc = "";
    protected void Page_Load(object sender, EventArgs e)
    {

        SqlParameter[] sqlparam = new SqlParameter[0];
        //SqlDataReader dr_fdoc = mgr.ExecuteQuery("get_topfeaturedDoc", sqlparam);
        //SqlDataReader dr_fdoc =CustomRepository.CustumExecutQuery("get_topfeaturedDoc", sqlparam);
        DataSet ds = CustomRepository.CustumDataSetFunction("get_top_5_featuredDoc", sqlparam);
        DataSet dsDen = CustomRepository.CustumDataSetFunction("get_top_5_featuredDen", sqlparam);
        DataSet dstop = CustomRepository.CustumDataSetFunction("get_top_3_featuredDoc", sqlparam);
        //DataSet dsDen_3top = CustomRepository.CustumDataSetFunction("get_top_3_featuredDent", sqlparam);
        try
        {

            if (ds.Tables[0].Rows.Count > 0)
            {
                featured_doc = "";
                localFunction obj = new localFunction();

                //for (int j = 0; j < 10; j++)
                //{
                for (int i = 0; i < 5; i++)
                {
                    string imgFinalPath = "", str_path = "";
                    if (ds.Tables[0].Rows[i]["photo"].ToString().Trim().Length > 0)
                    {
                        if (System.IO.File.Exists(Request.PhysicalApplicationPath + "//images//Dr_images//" + ds.Tables[0].Rows[i]["photo"].ToString()))
                        {
                            str_path = "./images/Dr_images/" + ds.Tables[0].Rows[i]["photo"].ToString();
                        }
                        else
                        {
                            str_path = "./images/Dr_images/silhouette-male.gif";
                        }
                    }
                    else
                    {
                        str_path = "./images/Dr_images/silhouette-male.gif";
                    }
                    imgFinalPath = str_path;
                    string Qstr = HttpContext.Current.Session["strHttp"] + "doctors/" + obj.URLFormat(ds.Tables[0].Rows[i]["speciality"].ToString(), ds.Tables[0].Rows[i]["state"].ToString(), ds.Tables[0].Rows[i]["city"].ToString(), true) + "/" + ds.Tables[0].Rows[i]["id"].ToString() + "-" + ds.Tables[0].Rows[i]["name"].ToString() + ".aspx";
                    featured_doc += "<div class=\"slide\"> <img  src=\"" + imgFinalPath + "\" alt=\"\" title=\" " + ds.Tables[0].Rows[i]["Name"].ToString() + "\" onclick=\"return viewDocProfile('" + Qstr + "');\" width='260px' height='270px' style='cursor:pointer' /> <div class=\"caption\" style=\"bottom:0\"><p>" + ds.Tables[0].Rows[i]["Name"].ToString() + "</p> <p>" + ds.Tables[0].Rows[i]["speciality"].ToString() + "</p></div></div>";
                }
                for (int i = 0; i < dsDen.Tables[0].Rows.Count; i++)
                {
                    string imgFinalPath = "", str_path = "";
                    if (dsDen.Tables[0].Rows[i]["photo"].ToString().Trim().Length > 0)
                    {
                        if (System.IO.File.Exists(Request.PhysicalApplicationPath + "//images//Dnt_images//" + dsDen.Tables[0].Rows[i]["photo"].ToString()))
                        {
                            str_path = "./images/Dnt_images/" + dsDen.Tables[0].Rows[i]["photo"].ToString();
                        }
                        else
                        {
                            str_path = "./images/Dnt_images/silhouette-male.gif";
                        }
                    }
                    else
                    {
                        str_path = "./images/Dnt_images/silhouette-male.gif";
                    }
                    imgFinalPath = str_path;

                    string Qstr = HttpContext.Current.Session["strHttp"] + "dentists/" + obj.URLFormat(dsDen.Tables[0].Rows[i]["speciality"].ToString(), dsDen.Tables[0].Rows[i]["state"].ToString(), dsDen.Tables[0].Rows[i]["city"].ToString(), true) + "/" + dsDen.Tables[0].Rows[i]["id"].ToString() + "-" + dsDen.Tables[0].Rows[i]["name"].ToString() + ".aspx";
                    featured_doc += "<div class=\"slide\"> <img  src=\"" + imgFinalPath + "\" alt=\"\" title=\" " + dsDen.Tables[0].Rows[i]["Name"].ToString()+ "\" onclick=\"return viewDocProfile('" + Qstr + "');\" width='260px' height='270px' style='cursor:pointer' /> <div class=\"caption\" style=\"bottom:0\"><p>" + dsDen.Tables[0].Rows[i]["Name"].ToString() + "</p> <p>" + dsDen.Tables[0].Rows[i]["speciality"].ToString() + " </p></div></div>";
                }


                // }


                for (int i = 0; i < dstop.Tables[0].Rows.Count; i++)
                {
                    string toprated_imgFinalPath = "";

                    if (dstop.Tables[0].Rows[i]["photo"].ToString().Trim().Length > 0)
                    {
                        if (System.IO.File.Exists(Request.PhysicalApplicationPath + "//images//Dr_images//" + dstop.Tables[0].Rows[i]["photo"].ToString()))
                        {
                            toprated_imgFinalPath = mgr.getThumbnaleImage("images/Dr_images/" + dstop.Tables[0].Rows[i]["photo"].ToString(), 145, 130, false, "");
                            //toprated_imgFinalPath = "./images/Dr_images/" + ds.Tables[0].Rows[i]["photo"].ToString();
                        }
                        else
                        {
                            toprated_imgFinalPath = mgr.getThumbnaleImage("images/Dr_images/silhouette-male.gif", 145, 130, false, "");
                            //toprated_imgFinalPath = "./images/Dr_images/silhouette-male.gif";
                        }
                    }
                    else
                    {
                        //toprated_imgFinalPath = "./images/Dr_images/silhouette-male.gif";
                        toprated_imgFinalPath = mgr.getThumbnaleImage("images/Dr_images/silhouette-male.gif", 145, 130, false, "");
                        //str_path = mgr.getThumbnaleImage(Session["strHttp"] + "images/Dr_images/silhouette-male.gif", 111, 128, false, "");
                    }


                    string url = HttpContext.Current.Session["strHttp"] + "doctors/" + obj.URLFormat(dstop.Tables[0].Rows[i]["speciality"].ToString(), dstop.Tables[0].Rows[i]["state"].ToString(), dstop.Tables[0].Rows[i]["city"].ToString(), true) + "/" + dstop.Tables[0].Rows[i]["id"].ToString() + "-" + dstop.Tables[0].Rows[i]["name"].ToString() + ".aspx";
                    top_rated_doc += "<div class=\"left\"> <a href=\"" + url + "\"> " + toprated_imgFinalPath + " </a> </div>";
                    //top_rated_doc += "<div class=\"left\"> <a href=\"" + url + "\"> <img src=\"" + toprated_imgFinalPath + "\" alt=\"" + ds.Tables[0].Rows[i]["Speciality"].ToString() + "\" width=\"145px\" height=\"110px\" /> </a> </div>";
                    top_rated_doc += "<div class=\"right\"> <p>" + dstop.Tables[0].Rows[i]["Name"].ToString() + "</p> <p>" + dstop.Tables[0].Rows[i]["Speciality"].ToString() + "</p> </div>  <div class=\"cl\">&nbsp;</div>";
                }
                // for (int i = 0; i < dsDen_3top.Tables[0].Rows.Count; i++)
                //{
                //    string toprated_imgFinalPath = "";

                //    if (dsDen_3top.Tables[0].Rows[i]["photo"].ToString().Trim().Length > 0)
                //    {
                //        if (System.IO.File.Exists(Request.PhysicalApplicationPath + "//images//Dr_images//" + dsDen_3top.Tables[0].Rows[i]["photo"].ToString()))
                //        {
                //            toprated_imgFinalPath = mgr.getThumbnaleImage("images/Dr_images/" + dstop.Tables[0].Rows[i]["photo"].ToString(), 145, 130, false, "");
                //            //toprated_imgFinalPath = "./images/Dr_images/" + ds.Tables[0].Rows[i]["photo"].ToString();
                //        }
                //        else
                //        {
                //            toprated_imgFinalPath = mgr.getThumbnaleImage("images/Dr_images/silhouette-male.gif", 145, 130, false, "");
                //            //toprated_imgFinalPath = "./images/Dr_images/silhouette-male.gif";
                //        }
                //    }
                //    else
                //    {
                //        //toprated_imgFinalPath = "./images/Dr_images/silhouette-male.gif";
                //        toprated_imgFinalPath = mgr.getThumbnaleImage("images/Dr_images/silhouette-male.gif", 145, 130, false, "");
                //        //str_path = mgr.getThumbnaleImage(Session["strHttp"] + "images/Dr_images/silhouette-male.gif", 111, 128, false, "");
                //    }


                //    string url = HttpContext.Current.Session["strHttp"] + "doctors/" + obj.URLFormat(dsDen_3top.Tables[0].Rows[i]["speciality"].ToString(), dsDen_3top.Tables[0].Rows[i]["state"].ToString(), dsDen_3top.Tables[0].Rows[i]["city"].ToString(), true) + "/" + dsDen_3top.Tables[0].Rows[i]["id"].ToString() + "-" + dsDen_3top.Tables[0].Rows[i]["name"].ToString() + ".aspx";
                //    top_rated_doc += "<div class=\"left\"> <a href=\"" + url + "\"> " + toprated_imgFinalPath + " </a> </div>";
                //    //top_rated_doc += "<div class=\"left\"> <a href=\"" + url + "\"> <img src=\"" + toprated_imgFinalPath + "\" alt=\"" + ds.Tables[0].Rows[i]["Speciality"].ToString() + "\" width=\"145px\" height=\"110px\" /> </a> </div>";
                //    top_rated_doc += "<div class=\"right\"> <p>" + dsDen_3top.Tables[0].Rows[i]["Name"].ToString() + "</p> <p>" + dsDen_3top.Tables[0].Rows[i]["Speciality"].ToString() + "</p> </div>  <div class=\"cl\">&nbsp;</div>";
                //}

            }


            //if (dr_fdoc.Read())
            //{
            //    dr_id = dr_fdoc["id"].ToString();
            //    lbl_docna.Text = dr_fdoc["Name"].ToString();
            //   // lnk_EmailToDoctor.Text = "Email Dr. " + dr_fdoc["Name"].ToString();
            //   // lnk_EmailToDoctor.NavigateUrl = Session["StrHttp"] + "Doctor/EmailToDoctor.aspx?Id=" + dr_id;

            //    lbl_add.Text = dr_fdoc["Location"].ToString();
            //    lbl_spec.Text = dr_fdoc["Speciality"].ToString();

            //    double overallrate = Math.Round(Convert.ToDouble(dr_fdoc["training"]) + Convert.ToDouble(dr_fdoc["expertise"]) + Convert.ToDouble(dr_fdoc["patreview"]), 2);
            //    lbl_rate.Text = (overallrate > 100) ? "100" : overallrate.ToString();
            //    string str_path = String.Empty;
            //    if (dr_fdoc["photo"].ToString().Trim().Length > 0)
            //    {
            //        if (System.IO.File.Exists(Request.PhysicalApplicationPath + "//images//Dr_images//" + dr_fdoc["photo"].ToString()))
            //            str_path = mgr.getThumbnaleImage("./images/Dr_images/" + dr_fdoc["photo"].ToString(), 130, 100, false, "");
            //        else
            //            str_path = mgr.getThumbnaleImage("./images/Dr_images/silhouette-male.gif", 80, 100, false, "");
            //    }
            //    else
            //    {
            //        str_path = mgr.getThumbnaleImage("./images/Dr_images/silhouette-male.gif", 80, 100, false, "");
            //        //str_path = mgr.getThumbnaleImage(Session["strHttp"] + "images/Dr_images/silhouette-male.gif", 111, 128, false, "");
            //}
            //imgTag.Text = str_path;
            //// Commented as images are not being fetched any more using handler
            //// Date: 11th April 08
            //// imgTag.Text = dr_fdoc["id"].ToString();
            //gender.Text = dr_fdoc["gender"].ToString();
            //TrainingRate.rate = Convert.ToDecimal(dr_fdoc["training"].ToString());
            //TrainingRate.totalScore = 25;
            //ExpertiseRate.rate = Convert.ToDecimal(dr_fdoc["expertise"].ToString());
            //ExpertiseRate.totalScore = 55;
            //PatientRate.rate = Convert.ToDecimal(dr_fdoc["patreview"].ToString());
            //PatientRate.totalScore = 20;
            //CostRate.rate = Convert.ToDecimal(dr_fdoc["cost"].ToString());

            //localFunction obj = new localFunction();
            ////Comented for implement new URL Formate at 16/07/08 by Ranjeet 

            //    //string Qstr = obj.FormatURL(dr_fdoc["speciality"].ToString(), dr_fdoc["SubSpec"].ToString(), dr_fdoc["state"].ToString(), dr_fdoc["city"].ToString(), dr_fdoc["ZipCode"].ToString(), true);
            //    //btnProfile.Attributes.Add("onclick", "return viewDocProfile('" + dr_id + Qstr + "');"); // Deepak - Navigates to Profile Page


            //    string Qstr = HttpContext.Current.Session["strHttp"] + "doctors/" + obj.URLFormat(dr_fdoc["speciality"].ToString(), dr_fdoc["state"].ToString(), dr_fdoc["city"].ToString(), true) + "/" + dr_id + "-" + dr_fdoc["name"].ToString() + ".aspx";
            //    btnProfile.Attributes.Add("onclick", "return viewDocProfile('"  + Qstr + "');"); // Deepak - Navigates to Profile Page

            //    //hlnk_drP.NavigateUrl = Session["StrHttp"] + "doctor/DoctorsDetails.aspx?id=" + dr_id;
            //    //lbl_docna.NavigateUrl = Session["StrHttp"] + "doctor/DoctorsDetails.aspx?id=" + dr_id;
            //    //hlnk_patrev.NavigateUrl = Session["StrHttp"] + "doctor/doctorViewMessage.aspx?id=" + dr_id;
            //    //hlnk_peer.NavigateUrl = Session["StrHttp"] + "doctor/DoctorsDetails.aspx?id=" + dr_id;
            //    dr_fdoc.Close();
            //    dr_fdoc.Dispose();
            //}
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
    protected void btnProfile_Click(object sender, EventArgs e)
    {


    }
    //obj.FormatURL(Eval("specialityName"),Eval("subSpec"),Eval("state"),Eval("city"),Eval("zipcode"), true)
}
